<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>arguments</title>
</head>
<body>

<ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
</ul>
<script>


    let liList = document.querySelectorAll("li");

    console.log(liList)

//    arguments 函数内部的参数集合 伪数组/类数组(下标,长度,原型(__proto__)不指向Array ==> likeArray)

// 类数组 --> 类似
// 类数组转换成数组 ==>
//   for
//   Array.from
//   Array.prototype.slice.call(arguments) 类数组转换成数组
//


//    [].slice()
//    Array.prototype.slice();//this --> []

//重写slice方法
//    Array.prototype.slice = function(){ //this --> []
//
//    }

Array.prototype.myFn = function () {
    alert("MyFn Run");
    console.log(this);//arr []
};

//不传参的slice方法模拟
Array.prototype.mySlice = function () {
    let newArr = [];
//    newArr = [...this];

    for (let i = 0; i < this.length; i++) {
        newArr.push(this[i])
    }


    return newArr

};


// 求和:  字符串, 数组(数字,字符,布尔)  对象  null undefined


/*    /!**
 * 求和
 * @param {Number} num1
 * @param num2
 * @returns {Number} sumNum
 *!/*/
function sum(num1, num2) {//封装 思路: 保证参数数据类型的一致性 容错处理(稳定性) 说明
    //数据类型判断
    console.log(arguments);
    console.log(Array.from(arguments));

    //性能
    let newArgs = Array.prototype.slice.call(arguments);
//    let newArgs = [].slice.call(arguments);
//    let newArgs = Array.from(arguments);
//    let newArgs = [...arguments];

    console.log(newArgs);

    let sumNum = 0;

    for (let i = 0; i < arguments.length; i++) {
        sumNum += arguments[i]
    }

    return sumNum
}

console.log(sum(1,2,3,4))

/*    console.time("aa");

 console.dir({});
 console.dir([]);
 console.error("......111.....");

 console.time("aa1");
 console.log(sum(1));//1

 console.log(sum(1, 2));//3

 console.log(sum(1,2,3,4));//3

 console.timeEnd("aa1");
 console.timeEnd("aa");*/




/*
Number.prototype.toTreeString=function () {
    console.log(this)
};

    let a  = 2231238764;
a.toTreeString();
    a  = "2,231,238,764.00";
    "asd".toTreeString()*/

</script>
</body>
</html>